import service from "@/server/serviceIndex";
// 根据用户Id更改用户数据表的基本信息
export const upDateUserInfo = (body) => {
  return service({
    method: "post",
    url: "/pipayshopapi/user-info/updateUserInfoByUid",
    data: body,
  });
};
// 上传用户头像接口
export const upLoadUserImage = ({ userId, data }) => {
  return service({
    method: "post",
    url: `/pipayshopapi/user-info/uploadUserImage?userId=${userId}`,
    headers: { "Content-Type": "multipart/form-data" },
    data,
  });
};
// 校验二维码接口
export const verifyQrcode = (qrcode) => {
  return service({
    method: "POST",
    // url: `/pipayshopapi/shop-info/checkId?qrcode=${qrcode}`,
    url: `/pipayshopapi/shop-info/checkId`,
    data: qrcode,
  });
};
// 付款接口
export const payment = (head) => {
  return service({
    method: "post",
    url: `/pipayshopapi/transaction-record/recordTransaction?token=${head}`,
  });
};
// 生成酒店未支付订单
export const LiveOrderApi = (head) => {
  return service({
    method: "post",
    url: `/pipayshopapi/shop-order/generateUnpaidLiveOrder?token=${head}`,
  });
};
// 生成酒店支付订单
export const payLiveOrderApi = (head) => {
  return service({
    method: "post",
    url: `/pipayshopapi/shop-order/payLiveOrder?token=${head}`,
  });
};
// 插入交易表
export const hotelTransactionApi = (head) => {
  return service({
    method: "post",
    url: `/pipayshopapi/shop-order/hotelTransaction?token=${head}`,
  });
};
// 插入酒店记录表
export const createShopHotelRecordApi = (shopHotelRecord) => {
  return service({
    method: "post",
    url: `/pipayshopapi/shop-hotel-record/createShopHotelRecord`,
    data: shopHotelRecord,
  });
};

// 根据用户Id查找用户数据表的基本信息;
export const selectUserInfoByUid = (userId) => {
  return service({
    method: "get",
    url: `/pipayshopapi/user-info/selectUserInfoByUid/${userId}`,
  });
};

// 修改密码
export const updatePassWord = (piName, passWord) => {
  return service({
    method: "post",
    url: "pipayshopapi/b-user-info/updatePassWord",
    params: {
      piName,
      passWord,
    },
  });
};

export const collectList = ({ pages, limit, userId }) => {
  return service({
    method: "get",
    url: `/pipayshopapi/item-commodity-info/collectList/${pages}/${limit}/${userId}`,
    // params: {
    //   pages,
    //   limit,
    //   userId,
    // },
  });
};

// PayPal付款创建订单
export const requestOrder = (data) => {
  return service({
    method: "post",
    url: "pipayshopapi/account-info/api/orders",
    data,
  });
};

// PayPal批准订单
export const requestApprove = (orderId) => {
  return service({
    method: "post",
    url: `pipayshopapi/account-info/api/orders/${orderId}/capture`,
  });
};
